package com.damai.lang;

import java.lang.reflect.InvocationTargetException;

import com.damai.error.ApiError;

public class Lang {
	
	public static <T> T[] toArray(T...args){
		return args;
	}

	public static Throwable getCourse(Throwable e) {
		if(e instanceof ApiError){
			return e;
		}
		
		if(e instanceof InvocationTargetException){
			return getCourse(  ((InvocationTargetException)e).getTargetException()); 
		}
		
		//这里需要查询一下是否是真的
		Throwable t = ((Exception)e).getCause();
		if(t==null){
			return e;
		}
		
		return getCourse(t);
	}
}
